/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package View.User;


import Controllers.ActorController;
import Controllers.ArtistController;
import Controllers.DirectorController;
import Controllers.MovieController;
import View.Administrator.LoginAdmin;
import Entities.Actor;
import Entities.Artist;
import Entities.Director;
import Entities.Movie;
import Entities.Soundtrack;
import Services.ActorService;
import Services.SoundtrackService;
import javax.swing.UIManager;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.TypedQuery;
import javax.swing.JLabel;
import javax.swing.UnsupportedLookAndFeelException;
/**
 *
 * @author sebastian
 */
public class GRLU_MainView extends javax.swing.JFrame {
     MovieController mC = new MovieController(); 
     ActorController aC = new ActorController();
     ArtistController arC = new ArtistController();
     DirectorController dC = new DirectorController();
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("GRLU");
        EntityManager em2 = emf.createEntityManager();
        

    /**
     * Creates new form GRLU_MainView
     */
    public GRLU_MainView() {
        
        try {
            UIManager.setLookAndFeel("com.seaglasslookandfeel.SeaGlassLookAndFeel");
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(GRLU_MainView.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            Logger.getLogger(GRLU_MainView.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(GRLU_MainView.class.getName()).log(Level.SEVERE, null, ex);
        } catch (UnsupportedLookAndFeelException ex) {
            Logger.getLogger(GRLU_MainView.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        initComponents();
//        if (em2.){
//        
//        }
//        
//        else(){
        jListResults.setListData(mC.getAllMoviesNames());
        jListResults.setSelectedIndex(0);
        ButtonViewMovie.setVisible(false);
        ButtonViewActor.setVisible(false);
        ButtonViewArtist.setVisible(false);
        ButtonViewDirector.setVisible(false);

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTextQuery = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jComboTypeQuery = new javax.swing.JComboBox();
        jButtonAdmin = new javax.swing.JButton();
        jButtonFind = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jListResults = new javax.swing.JList();
        labelAditResults = new javax.swing.JLabel();
        ButtonViewMovie = new javax.swing.JButton();
        ButtonViewDirector = new javax.swing.JButton();
        ButtonViewActor = new javax.swing.JButton();
        ButtonViewArtist = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("General Retailers Group C");

        jTextQuery.setText("Find Movie, actor or director");
        jTextQuery.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTextQueryMouseClicked(evt);
            }
        });
        jTextQuery.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextQueryActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Ubuntu", 1, 18)); // NOI18N
        jLabel1.setText("You can find the movie that u want to rent providing us, one of the following fields:");

        jComboTypeQuery.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Movie name", "Actor’s name", "Artist’s name", "Director’s name", "Genre" }));
        jComboTypeQuery.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jComboTypeQueryItemStateChanged(evt);
            }
        });
        jComboTypeQuery.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboTypeQueryActionPerformed(evt);
            }
        });

        jButtonAdmin.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jButtonAdmin.setForeground(new java.awt.Color(2, 10, 130));
        jButtonAdmin.setText("ADMIN");
        jButtonAdmin.setToolTipText("LOGIN TO ENTER OR MODIFY THE MOVIES IN THE DB");
        jButtonAdmin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAdminActionPerformed(evt);
            }
        });

        jButtonFind.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/User/lens_icon.png"))); // NOI18N
        jButtonFind.setText("Find   ");
        jButtonFind.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButtonFindMouseClicked(evt);
            }
        });
        jButtonFind.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonFindActionPerformed(evt);
            }
        });

        jListResults.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jListResults.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                jListResultsValueChanged(evt);
            }
        });
        jScrollPane1.setViewportView(jListResults);

        labelAditResults.setText("Our Latest Aditions:");

        ButtonViewMovie.setForeground(new java.awt.Color(255, 36, 0));
        ButtonViewMovie.setText("VIEW MOVIE INFO");
        ButtonViewMovie.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                ButtonViewMovieMouseClicked(evt);
            }
        });
        ButtonViewMovie.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButtonViewMovieActionPerformed(evt);
            }
        });

        ButtonViewDirector.setForeground(new java.awt.Color(255, 36, 0));
        ButtonViewDirector.setText("VIEW DIRECTOR INFO");
        ButtonViewDirector.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                ButtonViewDirectorMouseClicked(evt);
            }
        });
        ButtonViewDirector.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButtonViewDirectorActionPerformed(evt);
            }
        });

        ButtonViewActor.setForeground(new java.awt.Color(255, 36, 0));
        ButtonViewActor.setText("VIEW ACTOR INFO");
        ButtonViewActor.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                ButtonViewActorMouseClicked(evt);
            }
        });
        ButtonViewActor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButtonViewActorActionPerformed(evt);
            }
        });

        ButtonViewArtist.setForeground(new java.awt.Color(255, 36, 0));
        ButtonViewArtist.setText("VIEW ARTIST INFO");
        ButtonViewArtist.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                ButtonViewArtistMouseClicked(evt);
            }
        });
        ButtonViewArtist.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButtonViewArtistActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(32, 32, 32)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jComboTypeQuery, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(32, 32, 32)
                                .addComponent(jTextQuery, javax.swing.GroupLayout.PREFERRED_SIZE, 337, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jButtonFind, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(41, 41, 41)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(ButtonViewMovie, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(ButtonViewActor, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(ButtonViewArtist, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(ButtonViewDirector, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(30, 30, 30)
                                .addComponent(jButtonAdmin))
                            .addComponent(jScrollPane1)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(labelAditResults)
                                .addGap(0, 0, Short.MAX_VALUE)))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(52, 52, 52)
                .addComponent(jLabel1)
                .addGap(55, 55, 55)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboTypeQuery, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextQuery, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonFind))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(labelAditResults)
                .addGap(7, 7, 7)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 252, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ButtonViewMovie, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonAdmin)
                    .addComponent(ButtonViewDirector, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ButtonViewActor, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ButtonViewArtist, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(41, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jTextQueryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextQueryActionPerformed
      
    }//GEN-LAST:event_jTextQueryActionPerformed

    private void jButtonAdminActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAdminActionPerformed
        LoginAdmin login = new LoginAdmin();
        login.setLocationRelativeTo(this);
        login.setVisible(rootPaneCheckingEnabled);
    }//GEN-LAST:event_jButtonAdminActionPerformed

    private void jTextQueryMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTextQueryMouseClicked
         jTextQuery.setText(null);
    }//GEN-LAST:event_jTextQueryMouseClicked

    private void jButtonFindMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonFindMouseClicked
        String typeOfQuery = jComboTypeQuery.getItemAt(jComboTypeQuery.getSelectedIndex()).toString();
        String userQuery = jTextQuery.getText();
        System.out.println(userQuery);
        if (!userQuery.isEmpty() && !userQuery.equals("Find Movie, actor or director")){
            switch (typeOfQuery) {
                case "Movie name":                    
                    List<Movie> resultsMovie = mC.getMoviesbyName(userQuery);
                    String[] namesofmovies = new String[resultsMovie.size()];
                    int i = 0;
                    for(Movie m: resultsMovie){
                        namesofmovies[i] = m.getName();
                        i++;
                    }
                    jListResults.setListData(namesofmovies);
                    labelAditResults.setText("Your Movie results:");
                    System.out.println("Busque la peli!");
                    break;
                case "Actor’s name":
                    List<Actor> resultsActor = aC.getActorbyName(userQuery);
                    String[] namesofActors = new String[resultsActor.size()];
                    int j = 0;
                    for(Actor a: resultsActor){
                        namesofActors[j] = a.getName() + " "+ a.getLastName();
                        j++;
                    }
                    jListResults.setListData(namesofActors);
                    labelAditResults.setText("Your Actor results:");
                    System.out.println("Busque el actor!");
                    
                    
                    break;
                case "Artist’s name":
                    List<Artist> resultsArtist = arC.getArtistbyName(userQuery);
                    
                    String[] namesofArtist = new String[resultsArtist.size()];
                    int k = 0;
                    for(Artist ar: resultsArtist){
                        namesofArtist[k] = ar.getName() + " "+ ar.getLastName();
                        k++;
                    }
                    jListResults.setListData(namesofArtist);
                    labelAditResults.setText("Your Artist results:");
                    System.out.println("Busque el artista!");
                    
                    break;
                case "Director’s name":
                    List<Director> resultsDirector = dC.getDirectorbyName(userQuery);
                    String[] namesofDirectors = new String[resultsDirector.size()];
                    int l = 0;
                    for(Director dir: resultsDirector){
                        namesofDirectors[l] = dir.getName() + " "+ dir.getLastName();
                        l++;
                    }
                    jListResults.setListData(namesofDirectors);
                    labelAditResults.setText("Your Director results:");    
                    System.out.println("Busque el Director!");
                    break;
                    
                  case "Genre":
                    List<Movie> resultsGenMovie = mC.getMoviesbyGenre(userQuery);
                    String[] namesofgenmovies = new String[resultsGenMovie.size()];
                    int m = 0;
                    for(Movie mov: resultsGenMovie){
                        namesofgenmovies[m] = mov.getName();
                        m++;
                    }
                    jListResults.setListData(namesofgenmovies);
                    labelAditResults.setText("Your Movie by Genre results:");
                    
                    System.out.println("Busque la peli por genero!");
                      break;    
            }
            
          
        }
        else if (userQuery.isEmpty() || userQuery.equals("Find Movie, actor or director")){
             jListResults.setListData(mC.getAllMoviesNames());
             jListResults.setSelectedIndex(0);
             labelAditResults.setText("Our Latest Aditions:");
        }
    }//GEN-LAST:event_jButtonFindMouseClicked

    private void jButtonFindActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonFindActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButtonFindActionPerformed

//<<<<<<< local
    private void ButtonViewMovieActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButtonViewMovieActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_ButtonViewMovieActionPerformed


    private void ButtonViewMovieMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ButtonViewMovieMouseClicked
        // TODO add your handling code here:
        String nameTheMovie = (String)jListResults.getSelectedValue();
        
        System.out.println("item"+nameTheMovie);
        MovieView viewMovie = new MovieView();
        Movie movie = new Movie();
        mC.getMoviesbyName(nameTheMovie);
        movie = mC.getSingleMovie(nameTheMovie);
        viewMovie.enterData(movie);
        
        viewMovie.setLocationRelativeTo(this);
        viewMovie.setVisible(rootPaneCheckingEnabled);
        
        
       
    }//GEN-LAST:event_ButtonViewMovieMouseClicked

    private void jListResultsValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jListResultsValueChanged
        // TODO add your handling code here:
        
     
        
    }//GEN-LAST:event_jListResultsValueChanged

    private void jComboTypeQueryItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboTypeQueryItemStateChanged
        // TODO add your handling code here:
         if(evt.getItem().equals("Movie name") ){
            ButtonViewMovie.setVisible(true);
            ButtonViewActor.setVisible(false);
            ButtonViewArtist.setVisible(false);
            ButtonViewDirector.setVisible(false);
            }
        else if(evt.getItem().equals("Actor’s name") ){
            ButtonViewActor.setVisible(true);
            ButtonViewMovie.setVisible(false);
            ButtonViewArtist.setVisible(false);
            ButtonViewDirector.setVisible(false);
        }
        else if(evt.getItem().equals("Artist’s name") ){
            ButtonViewArtist.setVisible(true);
            ButtonViewMovie.setVisible(false);
            ButtonViewActor.setVisible(false);
            ButtonViewDirector.setVisible(false);
        }
        else if(evt.getItem().equals("Director’s name") ){
            ButtonViewDirector.setVisible(true);
            ButtonViewMovie.setVisible(false);
            ButtonViewActor.setVisible(false);
            ButtonViewArtist.setVisible(false);
            
        }
         else{
            ButtonViewMovie.setVisible(false);
            ButtonViewActor.setVisible(false);
            ButtonViewArtist.setVisible(false);
            ButtonViewDirector.setVisible(false);
            }
    }//GEN-LAST:event_jComboTypeQueryItemStateChanged

    private void ButtonViewDirectorMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ButtonViewDirectorMouseClicked
        // TODO add your handling code here:
        String nameTheDirector = (String)jListResults.getSelectedValue();
        
        System.out.println("item"+nameTheDirector);
        DirectorView viewDirector = new DirectorView();
        Director director = new Director();
        dC.getDirectorbyName(nameTheDirector);
        director = dC.getSingleDirector(nameTheDirector);
        viewDirector.enterData(director);
        
        viewDirector.setLocationRelativeTo(this);
        viewDirector.setVisible(rootPaneCheckingEnabled);
    }//GEN-LAST:event_ButtonViewDirectorMouseClicked

    private void ButtonViewDirectorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButtonViewDirectorActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_ButtonViewDirectorActionPerformed

    private void ButtonViewActorMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ButtonViewActorMouseClicked
        // TODO add your handling code here:
        String nameTheActor = (String)jListResults.getSelectedValue();
        
        System.out.println("item"+nameTheActor);
        ActorView viewActor = new ActorView();
        Actor actor = new Actor();
        aC.getActorbyName(nameTheActor);
        actor = aC.getSingleActor(nameTheActor);
        viewActor.enterData(actor);
        
        viewActor.setLocationRelativeTo(this);
        viewActor.setVisible(rootPaneCheckingEnabled);
    }//GEN-LAST:event_ButtonViewActorMouseClicked

    private void ButtonViewActorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButtonViewActorActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_ButtonViewActorActionPerformed

    private void ButtonViewArtistMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ButtonViewArtistMouseClicked
        // TODO add your handling code here:
        String nameTheArtist = (String)jListResults.getSelectedValue();
        
        System.out.println("item"+nameTheArtist);
        ArtistView viewArtist = new ArtistView();
        Artist artist = new Artist();
        arC.getArtistbyName(nameTheArtist);
        artist = arC.getSingleArtist(nameTheArtist);
        viewArtist.enterData(artist);
        
        viewArtist.setLocationRelativeTo(this);
        viewArtist.setVisible(rootPaneCheckingEnabled);
    }//GEN-LAST:event_ButtonViewArtistMouseClicked

    private void ButtonViewArtistActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButtonViewArtistActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_ButtonViewArtistActionPerformed

    private void jComboTypeQueryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboTypeQueryActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jComboTypeQueryActionPerformed

//>>>>>>> other
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel("com.seaglasslookandfeel.SeaGlassLookAndFeel");
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(GRLU_MainView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(GRLU_MainView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(GRLU_MainView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(GRLU_MainView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                //CREATION OF SOME INITIAL DATA
                
                
                //
                //                ActorService soundtrack;
                //                soundtrack = new ActorService(em2);
                //                soundtrack.findActor(Long.parseLong("3"));
                //
                //
                //                 em2.getTransaction().begin();
                //                 Date date = new Date(12);
                //
                //                 TypedQuery<Movie> query = (TypedQuery<Movie>) em2.createQuery("SELECT m from Movie m");
                //                 List<Movie> results = query.getResultList();
                //
                //                 em2.close();
                //                 emf.close();
                //
                //
                //                 
                 
                 Toolkit tk = Toolkit.getDefaultToolkit();
                 Dimension screenSize = tk.getScreenSize();
                 int screenHeight = screenSize.height;
                 int screenWidth = screenSize.width;
                 GRLU_MainView jPrincipal = new GRLU_MainView();
                // jPrincipal.setSize(screenHeight / 2, screenWidth /2);
                 jPrincipal.setLocationRelativeTo(null);
                 jPrincipal.setVisible(true);
     
            }
            
            
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton ButtonViewActor;
    private javax.swing.JButton ButtonViewArtist;
    private javax.swing.JButton ButtonViewDirector;
    private javax.swing.JButton ButtonViewMovie;
    private javax.swing.JButton jButtonAdmin;
    private javax.swing.JButton jButtonFind;
    private javax.swing.JComboBox jComboTypeQuery;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JList jListResults;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField jTextQuery;
    private javax.swing.JLabel labelAditResults;
    // End of variables declaration//GEN-END:variables
}
